package pages;

import core.TestBase;
import org.openqa.selenium.By;
import org.testng.Assert;
import ui_test.TestData;
import utils.Log4Test;

/**
 * Created with IntelliJ IDEA.
 * User: u
 * Date: 7/21/14
 * Time: 12:58 AM
 * To change this template use File | Settings | File Templates.
 */
public class SavedDataPage extends GeneralPage {
    protected By userMail = By.xpath(".//div[contains(text(),'Электронная почтa')]/../div[@class='field']");
    protected By userName = By.xpath(".//div[contains(text(),'Ваше имя')]/../div[@class='field']");
    protected By userAddress = By.xpath(".//div[contains(text(),'Адрес для доставок')]/../div[@class='field']/div");
    protected By wishListLink = By.xpath(".//li[@class='profile-m-i']//a[contains(text(),'Списки желаний')]");

    public void savedDataVerify() {
        Log4Test.info("Verifying saved data");
        System.out.println(webDriver.findElement(userName).getText());
        Assert.assertTrue(webDriver.findElement(userMail).getText().equals(TestData.email));
        System.out.println(webDriver.findElement(userMail).getText());

        final String expectedAddr = TestData.deliveryCity + " , " + TestData.deliveryStreet + "," + " д." + TestData.deliveryHouse + " кв." + TestData.deliveryFlat;
        System.out.println(expectedAddr);
        System.out.println(webDriver.findElement(userAddress).getText());
        Assert.assertTrue(webDriver.findElement(userName).getText().equals(TestData.userName));

        Assert.assertEquals(webDriver.findElement(userAddress).getText(), expectedAddr);
        ;
    }

    public WishListPage wishListClick() {
        Log4Test.info("transferring to wishList page");
        webDriver.findElement(wishListLink).click();
        return new WishListPage();
    }

}
